/**
 * @file
 * @author  Tsin Smith <tsin.creator@gmail.com>
 *
 * @section DESCRIPTION
 *
 */

#ifndef __TSINIDE_MAINWINDOW_HPP__
#define __TSINIDE_MAINWINDOW_HPP__

#include <QMainWindow>
#include <QProcess>

namespace Ui {
        class MainWindow;
}

class MainWindow : public QMainWindow
{
        Q_OBJECT

public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();

protected:
        void closeEvent(QCloseEvent *event);

private slots:
        void on_action_New_triggered();
        void on_action_Open_triggered();
        void on_action_Save_triggered();
        void on_action_SaveAs_triggered();
        void on_action_Close_triggered();
        void on_action_Undo_triggered();
        void on_action_Cut_triggered();
        void on_action_Copy_triggered();
        void on_action_Paste_triggered();
        void on_action_Run_triggered();
        void on_action_Redo_triggered();
        void on_action_Options_triggered();

        void readTsinOutput();
        void onTsinFinished(int code, QProcess::ExitStatus status);
        void documentModified();

        void readSettings();

private:
        Ui::MainWindow *ui;

        QString curFilename;

        QProcess *curTsin;

        void newFile();
        void openFile();
        bool saveFile();
        bool saveFileAs();
        bool saveBeforeExit();
        bool closeFile();

        void makeScratch();
        bool loadFile(const QString &filename);
        bool saveFile(const QString &filename);

        void writeSettings();
};

#endif /* __TSINIDE_MAINWINDOW_HPP__ */
